<#include "../common/header.htm">
<div class="content-wrapper">
	<section class="content-header" style="margin-top: 20px;">
		<ol class="breadcrumb">
			<li><a href="${ctx}/">首页</a></li>
			<li class="active"><a href="${ctx}/datalog/list">日志管理</a></li>
			<li class="active"><a href="#">详情</a></li>
		</ol>
		<a class="btn-return" href="javascript:history.back(-1);">返回</a>
	</section>
	<section class="content">
		<div class="detail-info-box">
	        <h4>模块信息：</h4>
			<div class="form-group form-inline">
			    <div class="col-sm-6">
					<label class="input_text">模块标识：</label> 
					<span class="info">
						<#if moduleFlagMap?? && moduleFlagMap['${u.logId}']??>
							${moduleFlagMap['${u.logId}']}
						</#if>
					</span>
				</div>
				<div class="col-sm-6">
					<label class="input_text">数据ID：</label> 
					<span class="info" title="${u.beanId!}" id="beanId">${u.beanId!}</span>
					<input type="hidden" id="logId" value="${u.logId!}"></input>
				</div> 
			</div>
			<div class="form-group form-inline">
			    <div class="col-sm-6">
					<label class="input_text">操作人：</label> 
					<span class="info">${u.createUserName!}</span>
				</div>
				<div class="col-sm-6">
					<label class="input_text">操作时间：</label> 
					<span class="info">${u.createTime?string("yyyy-MM-dd HH:mm:ss")}</span>
				</div> 
			</div>
			<div class="form-group form-inline">
			    <div class="col-sm-6">
					<label class="input_text">操作类型：</label> 
					<span class="info" title="${u.actionType!}" id="actionType">
						${u.actionType.getName()!}
					</span>
				</div>
				<div class="col-sm-6">
					<label class="input_text">数据恢复状态：</label> 
					<span class="info">
						<#if u.dealWith == 0>
							未处理
						<#else>
							已处理
						</#if>
					</span>
				</div>
			</div>
			<div class="form-group form-inline">
			    <div class="col-sm-12">
					<label class="input_text">操作原因：</label> 
					<span class="info">
						${u.operationReason!}
					</span>
				</div>
			</div>
		</div>
		<div class="detail-process-wrapper">
			<div class="title-box">
				<span>修改详情信息</span>
			</div>
            <table class="table table-hover table-bordered table-striped">
				<thead>
					<tr>
						<th style="width:60px;">#</th>
						<th style="width:150px;">ID</th>
						<th style="width:200px;">字段</th>
						<th style="width:200px;">字段名</th>
						<th>旧值</th>
						<th>新值</th>
					</tr>
				</thead>
				<tbody>
					<#list dataOperationDetailLog as c>
						<tr>
							<td>${c_index+1}</td>
							<td>${c.detailId!}</td>
							<td>${c.field!}</td>
							<td>${c.fieldName!}</td>
							<td name="oldValue">${c.oldValue!}</td>
							<td name="newValue">${c.newValue!}</td>
						</tr>
					</#list>
				</tbody>
			</table>
		</div>
		<#if moduleFlagMap?? && moduleFlagMap['${u.logId}']??>
			<#if moduleFlagMap['${u.logId}'] == '修改交易主体' || moduleFlagMap['${u.logId}'] == '删除交易主体'>
				<div class="row" style="padding-top: 10px;">
					<div class="col-xs-6">
						<#if u.dealWith == 0>
							<button type="button" class="btn btn-warning pull-right" onclick="dealWith()"> 标记为已处理</button>
							<button type="button" class="btn btn-primary pull-right" style="margin-right: 5px;" onclick="restore()"> 恢复</button>
						</#if>
					</div>
				</div>
			</#if>
		</#if>
	</section>
</div>
<script>
	/** 恢复 **/
	function restore(){
		var beanIds = $('#beanId').text();
		var oldValue = $("td[name='oldValue']").text();
		var actionType = $('#actionType').text();;
		$.ajax({
			type : "post",
			url: '${ctx}/datalog/restore?beanIds='+beanIds+"&oldValue="+oldValue+"&actionType="+actionType,
			success : function(result) {
				if (result.result == "success") {
					toastr.success('恢复成功');
				}
			},
			error : function() {
				toastr.error('恢复失败');
			},
		});
	};
	/** 标记为已处理 **/
	function dealWith(){
		var logId = $('#logId').val();
		$.ajax({
			type : "post",
			url: '${ctx}/datalog/dealWith?logId='+logId,
			success : function(result) {
				if (result.result == "success") {
					window.location.reload();
				}
			},
			error : function() {
				toastr.error('标记失败');
			},
		});
	};
</script>
<#include "../common/footer.htm">
